package com.tianma315.admin.device.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.tianma315.admin.common.base.CoreServiceImpl;
import com.tianma315.admin.device.vo.MaintainRecordAndTypeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tianma315.admin.device.dao.MaintainRecordDao;
import com.tianma315.admin.device.domain.MaintainRecordDO;
import com.tianma315.admin.device.service.MaintainRecordService;

import java.util.List;

/**
 * 
 * <pre>
 * 设备维护记录表
 * </pre>
 * <small> 2019-05-22 16:08:48 | Aron</small>
 */
@Service
public class MaintainRecordServiceImpl extends CoreServiceImpl<MaintainRecordDao, MaintainRecordDO> implements MaintainRecordService {

    @Autowired
    private MaintainRecordDao maintainRecordDao;
    @Override
    public Page<MaintainRecordAndTypeVO> getMaintainRecordPage(Integer pageNumber, Integer pageSize, MaintainRecordDO maintainRecordDO) {
        // 查询列表数据
        Page<MaintainRecordAndTypeVO> page = new Page<>(pageNumber, pageSize);
        List<MaintainRecordAndTypeVO> maintainRecordAndTypeVOList = maintainRecordDao.getMaintainRecordPage(page,maintainRecordDO);
        page.setRecords(maintainRecordAndTypeVOList);
//        page.setTotal(maintainRecordAndTypeVOList.size());
        return page;
    }

    @Override
    public boolean addMaintainRecord(MaintainRecordDO maintainRecordDO) {
        maintainRecordDO.setState(0);
        return insert(maintainRecordDO);
    }

    @Override
    public boolean deleteMaintainRecord(Integer id) {
        MaintainRecordDO maintainRecordDO = new MaintainRecordDO();
        maintainRecordDO.setMaintainRecordId(id);
        maintainRecordDO.setState(1);
        return updateById(maintainRecordDO);
    }
}
